package com.share.io.filechange;

import java.io.File;

import org.apache.commons.io.monitor.FileAlterationListener;
import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;

public class FileChangeMonitor {
	FileAlterationMonitor monitor = null;

	public FileChangeMonitor(long interval) {
		 monitor = new FileAlterationMonitor(interval);  
	}
	
	 public void monitor(String path, FileAlterationListener listener) {  
		 FileAlterationObserver observer = new FileAlterationObserver(new File(path));  
		 monitor.addObserver(observer);  
		 observer.addListener(listener);  
	 }
	 public void stop() throws Exception{  
		 monitor.stop();
	 }
	 
	 public void start() throws Exception {
		 monitor.start();
	 }
}
